package com.client.service;

import com.client.pojo.Order;
import com.client.service.Impl.OrderServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "order-service", path = "/orders", fallback = OrderServiceFallback.class)
public interface OrderService {

    @PostMapping
    public ResponseEntity<Order> createOrder(@RequestBody Order order);

    @GetMapping("/{orderId}")
    public ResponseEntity<Order> getOrderById(@PathVariable("orderId") String orderId);

    @GetMapping("/user/{userId}")
    public ResponseEntity<List<Order>> listOrdersByUserId(@PathVariable("userId") String userId);

    @PutMapping("/{orderId}/status")
    public ResponseEntity<Void> updateOrderStatus(@PathVariable("orderId") String orderId,
                                                  @RequestParam("newStatus") Integer newStatus);

    @DeleteMapping("/{orderId}")
    public ResponseEntity<Void> deleteOrder(@PathVariable("orderId") String orderId);

    @PostMapping("/{orderId}/pay")
    public ResponseEntity<Boolean> payOrder(@PathVariable("orderId") String orderId);

}
